package cn.school.controller.localization;

import cn.school.common.api.CommonResult;
import cn.school.localization.entity.StudentPositionDo;
import cn.school.localization.service.StudentPositionService;
import cn.school.localization.vo.PositionInfoVo;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @className: StudentPositionController
 * @author: Alex
 * @date: 2023/3/25
 **/
@RestController
@RequestMapping("/student/position")
@Api(tags = "student position => 学生定位")
public class StudentPositionController {
	@Autowired
	private StudentPositionService studentPositionService;
	
	// 新增学生定位数据接口
	@PostMapping("/addPosition")
	public CommonResult<Integer> addPositon(@RequestBody PositionInfoVo vo) {
		int num = studentPositionService.addPosition(vo);
		if (num > 0) {
			return CommonResult.success();
		}
		return CommonResult.failed();
	}
	
	// 家长查询学生运动轨迹接口
	@PostMapping("/findStudentRunningTrace")
	public CommonResult<List<StudentPositionDo>> findStudentRunningTrace(@RequestBody PositionInfoVo vo) {
		List<StudentPositionDo> runningTrace = studentPositionService.getRunningTrace(vo);
		return CommonResult.success(runningTrace);
	}
}

